home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / examples / chap04 / Car.wrl < prev    next >
Text File  |  1996-10-14  |  2KB  |  67 lines

  1. #VRML V2.0 utf8
  2.  
  3. #
  4. # a car running on the street.
  5. # you get on/off the car by clicking it.
  6. #
  7.  
  8. # inline a scenary to make you realize your viewpoint is moving.
  9. Transform{
  10.         translation -20 0 0
  11.         rotation 0 1 0 1.57
  12.         children[
  13.         Inline{url "world.wrl"}
  14.         ]
  15. }
  16.  
  17. # your default viewpoint.
  18. DEF DEFAULT_VIEWPOINT Viewpoint{
  19.         position 5 2 20
  20.         orientation 0 1 0 1.0
  21. }
  22.  
  23. DEF CAR Transform{
  24.         children[
  25.  
  26.         # car itself.
  27.         Inline{url "CarBody.wrl"},
  28.  
  29.         # touch sensor to get on/off the car.
  30.         DEF CAR_TOUCH TouchSensor{},
  31.  
  32.         # viewpoint located at the driver's seat.
  33.         DEF CAR_VIEWPOINT Viewpoint{
  34.                 position 0 2 0
  35.                 orientation 0 1 0 3.14
  36.         }
  37.         ]
  38. }
  39.  
  40. DEF CAR_TIME TimeSensor{
  41.         loop TRUE
  42.         cycleInterval 6
  43. }
  44.  
  45. DEF CAR_POSINT PositionInterpolator{
  46.         key [0, 0.5, 1]
  47.         keyValue [0 0 0, 0 0 20, 0 0 0]
  48. }
  49.  
  50. DEF CAR_SCRIPT Script{
  51.         url "Car.class"
  52.  
  53.         # get on/off the car.
  54.         eventIn SFTime touched
  55.         eventOut SFBool bindCarViewpoint
  56.         eventOut SFBool bindDefaultViewpoint
  57. }
  58.  
  59. # make the car moving.
  60. ROUTE CAR_TIME.fraction_changed TO CAR_POSINT.set_fraction
  61. ROUTE CAR_POSINT.value_changed TO CAR.set_translation
  62.  
  63. # get on/off the car.
  64. ROUTE CAR_TOUCH.touchTime TO CAR_SCRIPT.touched
  65. ROUTE CAR_SCRIPT.bindCarViewpoint TO CAR_VIEWPOINT.set_bind
  66. ROUTE CAR_SCRIPT.bindDefaultViewpoint TO DEFAULT_VIEWPOINT.set_bind
  67.